import {
  ADD_ORDER,
  DEL_ORDER,
  UPDATE_ORDER,
  FIND_ORDER,
  FIND_ORDER_BY_ID,
  ON_SEARCH,
  UPDATE_RES,
  ADD_TEMPLATE,
  DEL_TEMPLATE,
  UPDATE_TEMPLATE,
  CHANGE_DEFAULT,
  TEMPLATE_ON_SEARCH,
  TEMPLATE_RES,
} from '../../constants/order';

// 新增订单：{ 新的订单信息 }
export const add_order = payload => ({ type: ADD_ORDER, payload });
// 删除订单：订单id
export const del_order = payload => ({ type: DEL_ORDER, payload });
// 更新订单：{ id, 需要更新的订单信息 }
export const update_order = payload => ({ type: UPDATE_ORDER, payload });
// 查找订单：{ 查找信息 }
export const find_order = payload => ({ type: FIND_ORDER, payload });
// 通过id查找订单：订单id
export const find_order_by_id = payload => ({
  type: FIND_ORDER_BY_ID,
  payload,
});

// 改变搜索状态 true/false
export const on_search = payload => ({ type: ON_SEARCH, payload });
export const update_res = payload => ({ type: UPDATE_RES, payload });

// 配送模板
//
export const add_template = payload => ({ type: ADD_TEMPLATE, payload });
// 删除 payload=id
export const del_template = payload => ({ type: DEL_TEMPLATE, payload });
// 编辑：payload={id, newState:{}}
export const update_template = payload => ({ type: UPDATE_TEMPLATE, payload });
// 设置默认模板 payload=id
export const change_default = payload => ({ type: CHANGE_DEFAULT, payload });
export const template_on_search = payload => ({
  type: TEMPLATE_ON_SEARCH,
  payload,
});
export const template_res = payload => ({ type: TEMPLATE_RES, payload });
